package com.String;

import java.util.Random;

public class StringTest {
    public static void main(String[] args) {
        String createCode=CreateCode(6);
    }
    //产生验证码
    public static String CreateCode(int n){
        //定义2个变量，一个是记住最终产生的随机验证码，一个是记住全部可用的字符
        String code="";
        String data="abcdefghijklmnopkrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        Random ra=new Random();
        ra.nextInt(data.length());
        for (int i = 0; i < n; i++) {
            code+=data.charAt(ra.nextInt(data.length()));
        }
        return  code;
    }

}
